<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modeling</title>
<?php echo importCSS("template.css|style.css|work-single.css|font.css");?>
<?php echo importJS("jquery.min.js");?>
</head>
<body>
<?php echo L('LANG_FONT');?>
<script> var THEME_ROOT = '__ROOT__/themes/' ; </script>
<div class="header clearfix">
	<div class="center">
    	<a href="<?php echo U('/index');?>"><div class="logo">
        	<img src="__ROOT__/themes/images/logo.png" />
        </div></a>
        <div class="menu">
        	<a href="<?php echo U('/work/index');?>" <?php echo ($nav_menu=="work"?" class='now'":"");?>><div><?php echo L('HEADER_WORK');?></div></a> <!-- class="now"-->
            <a href="<?php echo U('/contractor/index');?>" <?php echo ($nav_menu=="contractor"?" class='now'":"");?>><div><?php echo L('HEADER_CONTRACTOR');?></div></a>
            <a href="<?php echo U('/space/index');?>" <?php echo ($nav_menu=="space"?" class='now'":"");?>><div><?php echo L('HEADER_MY_SPACE');?></div></a>
        </div>
        <div class="search">
        	<div><img src="__ROOT__/themes/images/search.png" /></div>
        	<form method="get" action="<?php echo U('/work/index');?>" >
            <input type="text" id="search" name="name" value="<?php echo L('HEADER_SEARCH');?>" onfocus="if(value=='<?php echo L('HEADER_SEARCH');?>') {value=''} setStyleOne(this.id)" onblur="if (value=='') { value='<?php echo L('HEADER_SEARCH');?>' } setStyleTwo(this.id)"/>
            </form>
        </div>
        <?php if ($_cUser) { ?>
        <div class="signafter">
        	<a href="<?php echo U('/signout');?>"><div  class="outbutton"><?php echo L('HEADER_SIGN_OUT');?></div></a>
        	<a href="<?php echo U('/space/index');?>"><div class="word"><?php echo ($_cUser["username"]); ?></div></a>
        </div>
        <?php } else { ?>
        <div class="sign">
        	<a href="<?php echo U('/join');?>"><div><?php echo L('HEADER_JOIN');?></div></a>
            <a href="<?php echo U('/signin');?>"><div><?php echo L('HEADER_SIGN_IN');?></div></a>
        </div>
        <?php } ?>
    </div>
</div>
<div class="clear"></div>

<div class="main center clearfix">

	<div class="inforbox">
    	<div class="workname"><span class="strong"><?php echo (h($work["name"])); ?></span></div>
    	<span ID="favStatus">
        		<?php echo favStatus($_cUser,$work['id']);?>
        </span>
        <script>
        	function follow_func(url) {
        		$.getJSON(url,function(data) {
        			//console.log(data);
        			if (data.error > 0) {
        				alert(data.msg);
        			} else {
        				$("#favStatus").html(data.data); 
        			}
        		})
        	}
        	$(".action_follow").live("click",function() {
        		follow_func("<?php echo U('/work/fav/add/'.$work['id']);?>");
        	});
        	$(".action_cancel").live("click",function() {
        		follow_func("<?php echo U('/work/fav/cancel/'.$work['id']);?>");
        	});
        </script>
        <!--
        <a href="#"><div class=" button nofollow">CANCEL</div></a>
        <a href="#"><div class="follow button now">FOLLOW</div></a>
        -->
        <div class="clear"></div>
        <div class="border nameborder"></div>
        <div class="clear"></div>
        <div class="worksitupic bidding"></div><div class="worksitu"><span class="strong"><?php echo L('WORK_BIDDING');?></span></div>
        <div class="clear"></div>
        <div class="workset"><?php echo L('WORK_OWNER');?> : <span class="strong">David</span></div>
        <div class="clear"></div>
        <div class="worktime"><?php echo L('WORK_END_TIME');?> : <span class="strong"><?php echo date('Y-m-d',$work['endtime']);?></span></div>
        <div class="clear"></div>
        <div class="workbud"><?php echo L('CONTRACTOR_BUDGET');?> : <span class="strong">$ <?php echo (h($work["budget"])); ?></span></div>
        <div class="clear"></div>
        <div class="workaim"><?php echo L('WORK_AIM');?> : <span class="strong"><?php echo (h($work["aim"])); ?></span></div>
        <div class="clear"></div>
        <div class="worksummary"><?php echo L('WORK_OVERVIEW');?> : <span><?php echo (h($work["overview"])); ?></span></div>
        <div class="clear"></div>
        <div class="border"></div>
        <div class="clear"></div>
        <div class="workinvo"><?php echo L('WORK_INVOICE_REQUIRED');?> : <span class="strong"><?php echo ($work['op_receipt']?"YES":"NO"); ?></span></div>
        <div class="clear"></div>
        <div class="workin"><?php echo L('WORK_DAILY_REPORT');?> : <span class="strong"><?php echo ($work['op_report']?"YES":"NO"); ?></span></div>
        <div class="clear"></div>
        <div class="workin"><?php echo L('WORK_CASE_REQUIRED');?> : <span class="strong"><?php echo ($work['op_havedemo']?"YES":"NO"); ?></span></div>
        <div class="clear"></div>
        <div class="workin"><?php echo L('WORK_ONLINE_PAYMENT');?> : <span class="strong"><?php echo ($work['op_netpay']?"YES":"NO"); ?></span></div>
        <div class="clear"></div>
        <div class="workcer"><?php echo L('WORK_CERTIFICATION');?> : <span class="strong"><?php echo ($work['op_verify']?"YES":"NO"); ?></span></div>
        <div class="clear"></div>
    </div>
    
    <div class="bidbox">
    	<div class="bidsend">
    		<form id=bids_form method=post enctype="multipart/form-data">
        	<div class="upfile"><input type="file" name="attach" /></div><div id="upfile"></div>
        	<textarea type="text" id="word" name="content" onfocus="if(value=='<?php echo L('WORK_MESSAGES');?>'){value=''}; setStyleOne(this.id)" onblur="if(value==''){ value='<?php echo L('WORK_MESSAGES');?>' }; setStyleTwo(this.id)" <?php if ($_cUser) { ?> ><?php echo L('WORK_MESSAGES'); } else { ?> disabled  > PLEASE LOGIN FIRST  <?php } ?></textarea>
            <input type="text" id="money" name="money" value="Bid price" onfocus="if(value=='Bid price') {value=''} setStyleOne(this.id)" onblur="if (value=='') {value='Bid price'} setStyleTwo(this.id)"/>
            <div class="clear"></div>
            <?php if ($_cUser) { ?>
            	<a href="#" onclick="return $('#bids_form').submit();"><div class="button bidbutton"><?php echo L('WORK_BID');?></div></a>
            <?php } else { ?>
            	<a href="<?php echo U('/signin');?>"><div class="button bidbutton"><?php echo L('WORK_BID');?></div></a>
            <?php } ?>
            <input type="hidden" name="action" value="bid"/>
            <div class="clear"></div>
            </form>
        </div>
        <div class="clear"></div>
        <div class="bidtitle"><?php echo L('WORK_BIDDING');?></div>
        <div class="clear"></div>
    	<div class="bidlist">
    		<div class="listhead">
        		<div class="lhname"><?php echo L('WORK_NAME');?></div>
            	<div class="lhcountry"><?php echo L('WORK_COUNTRY');?></div>
            	<div class="lhtimes"><?php echo L('WORK_TALK_TIMES');?></div>
        	</div>
        	<div class="clear"></div>
        	<table>
        		<?php if(is_array($bider)): $i = 0; $__LIST__ = $bider;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr class="bidlistsingle">
    				<td class="bidname"><a href="<?php echo U('/contractor/view/'.$vo['uid']);?>"><?php echo ($vo["username"]); ?></a></td>
            		<td class="bidcountry"><?php echo M('country')->getFieldByCode($vo['country'],"en");?></td>
            		<td class="bidtimes"><?php echo msgcount($work['id'],$vo['uid']);?></td>
        		</tr><?php endforeach; endif; else: echo "" ;endif; ?>
        		<!--
                <tr class="bidlistsingle">
    				<td class="bidname"><a href="contractor-single.html">David</a></td>
            		<td class="bidcountry">China</td>
            		<td class="bidtimes">20</td>
        		</tr>
                <tr class="bidlistsingle">
    				<td class="bidname"><a href="contractor-single.html">David</a></td>
            		<td class="bidcountry">China</td>
            		<td class="bidtimes">20</td>
        		</tr>-->
        	</table>
            <div class="clear"></div>
    	</div>
        <div class="clear"></div>
        <!--<a href="<?php echo U('/work/view/'.$work['id'].'/bids');?>"><div class="button choose">Choose the WORKER</div></a>-->
        <div class="clear"></div>
	</div>
    
    <div class="messagebox">
    	
    	<form id="message_form" method="post">
  		<div class="messagesend">
        	<div class="typebox">
            	<div class="inputimg"><img src="__ROOT__/themes/images/client-type.png" /></div>
                <div class="inputname"><?php echo L('WORK_MESSAGE_TYPE');?></div>
                <div id="dropDownList1" class="dropDownList dropdown">
  					<select class="hide" name="type">
                    	<option value="0"><?php echo L('WORK_PLEASE_SELECT');?></option>
   						<option value="1"><?php echo L('WORK_ADVICE');?></option>
   						<option value="2"><?php echo L('WORK_TECHNICAL_ADVICE');?></option>
   						<option value="3"><?php echo L('WORK_FEATURE_SUGGESTIONS');?></option>
                    	<option value="4"><?php echo L('WORK_PROTOTYPE_ADVICE');?></option>
                        <option value="5"><?php echo L('WORK_OTHER');?></option>
  					</select>
  					<span class=""><?php echo L('WORK_PLEASE_SELECT');?></span>
            		<ul class="">
            		</ul>
        		</div>
        	</div>
            <textarea type="text" id="message" name="message" onfocus="if(value=='<?php echo L('WORK_MESSAGES');?>'){value=''}; setStyleOne(this.id)" onblur="if(value==''){ value='<?php echo L('WORK_MESSAGES');?>' }; setStyleTwo(this.id)" <?php if ($_cUser) { ?> ><?php echo L('WORK_MESSAGES'); } else { ?> disabled  > <?php echo L('WORK_PLEASE_LOGIN_FIRST');?>  <?php } ?></textarea>
            <div class="clear"></div>
            <input type="hidden" name="action" value="message"/>
            <?php if ($_cUser) { ?>
            	<a href="#" onclick="$('#message_form').submit();"><div class="button messagebutton"><?php echo L('WORK_SEND');?></div></a> 
            <?php } else { ?>
            	<a href="<?php echo U('/signin');?>"><div class="button messagebutton"><?php echo L('WORK_SEND');?></div></a>
            <?php } ?>
            <div class="clear"></div>
        </div>
        </form>
        
        <div class="messagetitle"><?php echo L('WORK_MESSAGES');?> (<?php echo msgcount($work['id']);?>)</div>
        <div class="clear"></div>
        <div class="messagelist">
        	<?php if(is_array($message)): $i = 0; $__LIST__ = $message;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="messagesingle">
            	<div class="pic"><img src="<?php echo getAvatar($vo);?>" width=50/></div>
                <div class="wordbox">
                	<div class="name"><a href="<?php echo U('/contractor/view/'.$vo['uid']);?>"><?php echo ($vo["username"]); ?></a></div>
                	<div class="word"><?php echo (h($vo["content"])); ?></div>
                    <!--<div class="time"></div>-->
                </div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div><?php endforeach; endif; else: echo "" ;endif; ?>
            <!--
            <div class="messagesingle">
            	<div class="pic"><img src="__ROOT__/themes/images/pimg.png" /></div>
                <div class="wordbox">
                	<div class="name"><a href="">David</a></div>
                	<div class="word">Sweet.</div>
                    <div class="time">14 minutes earlier</div>
                </div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>
            <div class="messagesingle">
            	<div class="pic"><img src="__ROOT__/themes/images/pimg.png" /></div>
                <div class="wordbox">
                	<div class="name"><a href="">David</a></div>
                	<div class="word">Sweet. I Love your style!</div>
                    <div class="time">14 minutes earlier</div>
                </div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>
            -->
        </div>
        <a href="<?php echo U('/work/view/'.$work['id'].'/message');?>"><div class="messagemore button"><?php echo L('INDEX_MORE');?></div></a>
    </div>

</div>

<div class="footer">

</div>
<?php echo importJS("downlist.js|input.js|signup.js");?>
</body>
</html>